const router = require("koa-router")();

const {
    roleApi
} = require("../../../controller/user/role")

const { check } = require("../../../middleware/routercheck")

const { veri } = require("../../../middleware/checkData")

router.get(
    "/role/byid/:id",
    veri(["id"], "Non empty", "params"),
    check("getrole"),
    roleApi)    // 根据 id 获取角色
router.get(
    "/role/onlyname",
    check("getrole"),
    roleApi)    // 根据 id 获取角色
router.get(
    "/role/list",
    veri(["pageNum", "pageSize"], "Non empty", "query"),
    check("getrole"),
    roleApi)    // 获取角色列表
router.post(
    "/role/add",
    veri(["rolename", "rolekey"], "Non empty", "request"),
    check("createrole"),
    roleApi)    // 添加角色
router.put(
    "/role/edit/:id",
    veri(["id"], "Non empty", "params"),
    check("editrole"),
    roleApi)    // 编辑角色
router.delete(
    "/role/remove/:id",
    veri(["id"], "Non empty", "params"),
    check("removerole"),
    roleApi)    // 删除角色

module.exports = router;